<script setup lang="ts">
import { ref } from 'vue';

const props = defineProps({
  userData: {
    type: Object,
    required: true
  }
});

// 用户统计数据
const userStats = ref({
  totalTrips: 8,
  totalNights: 24,
  totalSpent: '¥15,680',
  memberSince: '2023年5月'
});

// 最近活动
const recentActivities = ref([
  { id: 1, type: '预订', title: '预订了上海外滩华尔道夫酒店', date: '2024-05-10', icon: '🏨' },
  { id: 2, type: '收藏', title: '收藏了"日本樱花季旅行攻略"', date: '2024-05-08', icon: '❤️' },
  { id: 3, type: '评论', title: '评论了巴黎丽兹酒店', date: '2024-05-05', icon: '💬' },
  { id: 4, type: '预订', title: '预订了北京-上海的机票', date: '2024-05-01', icon: '✈️' }
]);
</script>

<template>
  <div class="user-profile">
    <h2 class="section-title">个人信息</h2>
    
    <div class="profile-stats">
      <div class="stat-card">
        <div class="stat-value">{{ userStats.totalTrips }}</div>
        <div class="stat-label">总行程</div>
      </div>
      <div class="stat-card">
        <div class="stat-value">{{ userStats.totalNights }}</div>
        <div class="stat-label">住宿天数</div>
      </div>
      <div class="stat-card">
        <div class="stat-value">{{ userStats.totalSpent }}</div>
        <div class="stat-label">消费总额</div>
      </div>
      <div class="stat-card">
        <div class="stat-value">{{ userStats.memberSince }}</div>
        <div class="stat-label">会员时长</div>
      </div>
    </div>
    
    <div class="profile-details">
      <h3>基本信息</h3>
      <div class="info-grid">
        <div class="info-item">
          <div class="info-label">姓名</div>
          <div class="info-value">{{ props.userData.name }}</div>
        </div>
        <div class="info-item">
          <div class="info-label">邮箱</div>
          <div class="info-value">{{ props.userData.email }}</div>
        </div>
        <div class="info-item">
          <div class="info-label">手机</div>
          <div class="info-value">{{ props.userData.phone }}</div>
        </div>
        <div class="info-item">
          <div class="info-label">会员等级</div>
          <div class="info-value">{{ props.userData.level }}</div>
        </div>
      </div>
    </div>
    
    <div class="recent-activities">
      <h3>最近活动</h3>
      <div class="activity-list">
        <div v-for="activity in recentActivities" :key="activity.id" class="activity-item">
          <div class="activity-icon">{{ activity.icon }}</div>
          <div class="activity-details">
            <div class="activity-title">{{ activity.title }}</div>
            <div class="activity-date">{{ activity.date }}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<style scoped>
.user-profile {
  color: #333;
}

.section-title {
  margin-top: 0;
  margin-bottom: 25px;
  font-size: 22px;
  color: #333;
  border-bottom: 1px solid #eee;
  padding-bottom: 15px;
}

.profile-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 15px;
  margin-bottom: 30px;
}

.stat-card {
  background-color: #f0f8ff;
  border-radius: 8px;
  padding: 20px;
  text-align: center;
}

.stat-value {
  font-size: 24px;
  font-weight: bold;
  color: #0066cc;
  margin-bottom: 5px;
}

.stat-label {
  color: #666;
  font-size: 14px;
}

.profile-details {
  margin-bottom: 30px;
}

.profile-details h3 {
  font-size: 18px;
  margin-bottom: 15px;
  color: #333;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.info-item {
  padding: 15px;
  background-color: #f9f9f9;
  border-radius: 8px;
}

.info-label {
  color: #666;
  font-size: 14px;
  margin-bottom: 5px;
}

.info-value {
  font-weight: 500;
}

.recent-activities h3 {
  font-size: 18px;
  margin-bottom: 15px;
  color: #333;
}

.activity-list {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.activity-item {
  display: flex;
  align-items: center;
  padding: 15px;
  background-color: #f9f9f9;
  border-radius: 8px;
}

.activity-icon {
  width: 40px;
  height: 40px;
  background-color: #f0f8ff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 15px;
  font-size: 20px;
}

.activity-title {
  font-weight: 500;
  margin-bottom: 5px;
}

.activity-date {
  font-size: 14px;
  color: #666;
}

@media (max-width: 768px) {
  .profile-stats {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .info-grid {
    grid-template-columns: 1fr;
  }
}
</style> 